<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>我的收藏</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link type="text/css" rel="stylesheet" href="statics/css/style.css" />


<script type="text/javascript"
	src="/EasyBuy/statics/js/jquery-1.8.2.min.js"></script>
<!-- <script type="text/javascript" src="/EasyBuy/statics/js/menu.js"></script>

<script type="text/javascript" src="/EasyBuy/statics/js/select.js"></script> -->


<title>尤洪</title>
</head>
<script type="text/javascript">
	$(document).ready(function() {					
	show();
		function show() {
			$.getJSON("/EasyBuy/CollectServlet","opr=list&uid=${applicationScope.id}", function(data){
				for ( var i = 0; i < data.length; i++) {
					$("#tlist").append("<tr><td style='font-family:'宋体';'><div class='sm_img'><img src='/EasyBuy/statics/images/"+data[i].fileName+"' width='48' height='48' /></div>"
															+ data[i].name
															+ "</td><td align='center'>￥"
															+ data[i].price
															+ ".00</td><td align='center'><a id='_"+data[i].id+"' style='color:#ff4e00;' class='add'>加入购物车</a>&nbsp; &nbsp; <a id='"+data[i].id+"' value='"+data[i].collectId+"' class='de'>删除</a></td></tr>");													
									/*<tr>
									<td style="font-family:'宋体';">
										<div class="sm_img">
											<img src="/EasyBuy/images/simg.jpg" width="48" height="48" />
										</div>法颂浪漫梦境50ML 香水\女士持久清新淡香 送2ML小样3只</td>
									<td align="center">￥456.00</td>
									<td align="center"><a href="#">关注</a>&nbsp; &nbsp; <a
							href="#" style="color:#ff4e00;">加入购物车</a>&nbsp; &nbsp; <a
							href="#">删除</a>
									</td>
									</tr>*/
		
				}
				$(".de").click(function(){
					$id=this.id;
					$.get("/EasyBuy/CollectServlet","opr=del&productId="+$id+"&userId=${applicationScope.id}",delback);	//死值
					function delback(data){
							if(data=="success"){
								alert("删除成功");
								location.href="/EasyBuy/backend/order/Member_Collect.jsp";
								$(this).parent().parent().remove();
							}else{
								$("#tlist").load("Member_Collect.jsp");
							}				
					}		
				});	
				
				$(".add").click(function(){
					$id=this.id;
					var h = $id.substring($id.lastIndexOf("_")+1);	//分割￥符号
					$.get("BuyCarServlet","opr=CollectionaddBuyCar&id=${applicationScope.id}&pid="+h,callback);
					function callback(data){
						if(data=="cg"){
							alert("添加成功");
							location.href="/EasyBuy/backend/order/Member_Collect.jsp";
						}else{
							alert("添加失败");
						}
					}
				});
			}); //用户编号   死值
						
		}
		
		$(".collect").attr("class","now");
	});
</script>
<body>
	<c:choose>
	  	<c:when test="${empty applicationScope.id}">
	  		<% response.sendRedirect("/EasyBuy/pre/Login.jsp");%>
	  	</c:when>
	  	<c:otherwise>
	  		<%@ include file="../../common/header.jsp" %>
			<%@ include file="../../common/backendHeader.jsp" %>
			 <c:choose>
				<c:when test="${empty applicationScope.type }">
					<% 	request.getRequestDispatcher("../../UserServlet?opr=type&href=Member_Address&href1=order").forward(request, response); %>
				</c:when>
				<c:otherwise>
					<c:if test="${applicationScope.type==1 }">
		  				<%@ include file="../../common/sideMamber.jsp" %> 
					</c:if>
					<c:if test="${applicationScope.type==0 }">
						<%@ include file="../../common/sideUser.jsp" %> 
					</c:if>
				</c:otherwise>
			 </c:choose>
	  	</c:otherwise>
  	</c:choose>
	
			<div class="m_right">
				<p></p>
				<div class="mem_tit">
					<span class="fr"
						style="font-size:12px; color:#55555; font-family:'宋体'; margin-top:5px;"></span>我的收藏
				</div>
				<table border="0" class="order_tab" style="width:930px;"
					cellspacing="0" cellpadding="0" id="tlist">
					<tr>
						<td align="center" width="420">商品名称</td>
						<td align="center" width="180">价格</td>
						<td align="center" width="270">操作</td>
					</tr>
				</table>
			</div>
		</div>
		<!--End 用户中心 End-->
</body>

</html>
